package sk.tuke.constraintbuilder.model;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;


@XmlRootElement(name = "template", namespace="sk.tuke.constraintbuilder")
public class Template extends RootElement{

	private ConditionsElement condition = new ConditionsElement();
	private RulesElement rule = new RulesElement();
	
	public Template(){
		super();
		super.setName("New Template [id  "+super.getId()+"]");
	}

	@XmlElement
	public ConditionsElement getCondition() {
		return condition;
	}

	public void setCondition(ConditionsElement condition) {
		this.condition = condition;
	}

	@XmlElement
	public RulesElement getRule() {
		return rule;
	}

	public void setRule(RulesElement rule) {
		this.rule = rule;
	}

	public boolean removeElement(RuleElement element) {
		boolean removed = false;
		if(rule!=null){
			 removed = rule.removeElement(element);
		}
		if(!removed && condition!=null){
			removed = condition.removeElement(element);
		}
		return removed;
	}
}
